package com.shen.thread.reflection;

public class Test1 {
    public static void main(String[] args) throws ClassNotFoundException {
        //forName
        Class c1 = Class.forName("com.shen.reflection.User");
        //对象
        Class c2 = new User().getClass();
        //类名.class
        Class<User> c3 = User.class;

        System.out.println(c1);
        System.out.println(c2);
        System.out.println(c3);
        //一个类在内存中只有一个class对象
        //一个类被加载后，整个结构都会被封装在class对象中

    }
}

class User {
    private int id;
    private String name;
    private int age;

    public User() {
    }

    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}